﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccess;
using Entities;

namespace Controller
{
    public class GetViewListController
    {
        public event GetViewListEventHandler GetViewListCompleted;

        public void OnGetViewListCompleted(GetViewListEventArgs e)
        {
            if (GetViewListCompleted != null)
                GetViewListCompleted(e);

        }

        public void GetViewList(ConnectionInformation CI)
        {
            List<string> result = new List<string>();
            string message = String.Empty;

            try
            {
                if (CI.DataBaseType == DataBaseType.MSSQLServer)
                {
                    MSSQLDataAccess mSSQLDataAccess = new MSSQLDataAccess();
                    result=mSSQLDataAccess.GetViewList(CI);
                }
                if (CI.DataBaseType == DataBaseType.MySQL)
                {
                    MySQLDataAccess mySQLDataAccess = new MySQLDataAccess();
                    result = mySQLDataAccess.GetViewList(CI);
                }
                OnGetViewListCompleted(new GetViewListEventArgs(result));
            }

            catch (Exception ex)
            {
                OnGetViewListCompleted(new GetViewListEventArgs(ex));
            }

            
        }
    }
}
